import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state() {
    return {
      admin: null,
      user: null,
      frontQuery: {
        page: 1,
        pageSize: 20,
        name: ''
      },
      plant: null
    }
  },
  getters: {
  },
  mutations: {
    setAdmin(state, admin) {
      state.admin = admin;
    },
    setUser(state, user) {
      state.user = user;
    },
    setFrontQuery(state, queryInfo) {
      state.frontQuery.name = queryInfo.name ?? '';
      state.frontQuery.page = queryInfo.page ?? 1;
      state.frontQuery.pageSize = queryInfo.pageSize ?? state.frontQuery.pageSize;
    },
    setPlant(state, plant) {
      state.plant = plant;
    }
  },
  actions: {
  },
  modules: {
  }
})
